package com.iplay.dao.favourites;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;

import com.iplay.entity.favourites.FavouritesTargetType;
import com.iplay.entity.favourites.UserFavouritesDO;

public interface UserFavouritesDAO extends CrudRepository<UserFavouritesDO, Integer> {
	
	Page<UserFavouritesDO> findByUserId(int userId, Pageable pageable);
	
	UserFavouritesDO findByUserIdAndTargetIdAndTargetType(int userId, int targetId, FavouritesTargetType targetType);
	
	@Transactional
	@Modifying
	void deleteByUserIdAndTargetIdAndTargetType(int userId, int targetId, FavouritesTargetType targetType);
}
